package client

import (
	"fmt"
	"github.com/urfave/cli/v2"
	"ycontainer/cgroups"
	"ycontainer/container"
)

func RunAction(context *cli.Context) error {
	if context.Args().Len() == 0 {
		return fmt.Errorf("missing args")
	}

	verifyParams(context)

	resourceLimit := &cgroups.ResourceLimit{
		Memory: context.String("memory"),
	}

	createParams := &container.CreateParams{
		Name:            context.String("name"),
		ImageName:       context.Args().Get(0),
		Detach:          context.Bool("detach"),
		StartCmdAndArgs: context.Args().Tail(),
		Volumes:         context.StringSlice("volume"),
		ResourceLimit:   resourceLimit,
		Network:         context.String("network"),
	}
	c := &container.Container{
		CreateParams: createParams,
	}
	return c.Create()
}

func verifyParams(context *cli.Context) {

}
